#!/bin/env python

import websocket
import json

symbols = set()


def on_message(ws, message):
  msg = json.loads(message)
  symbol = msg['data'][0]['symbol']
  if symbol not in symbols:
    print(symbol)
    symbols.add(symbol)


def on_open(ws):
  pass


if __name__ == '__main__':
  ws = websocket.WebSocketApp('wss://www.bitmex.com/realtime?subscribe=orderBookL2',
                              on_message=on_message)
  ws.on_open = on_open
  ws.run_forever()
